﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Baosight.ZNH.ZMCommon;
using Baosight.ZNH.ZMCL.UI.Blocks;
using Telerik.Windows.Controls;
using Baosight.Platform.Core;
using Baosight.Platform.Core.UI.Controls;
using System.Text;
using System.Windows.Browser;

namespace Baosight.ZNH.ZMCL.UI
{
    public partial class ZMCLB0 : EFViewCmes
    {
        private RiskBlock _block = new RiskBlock();
        public ZMCLB0()
        {
            InitializeComponent();
            base.BeforeAction += OnBeforeAction;
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="initData"></param>
        public override void Initialize(EIInfo initData)
        {
            initData.AddBlock(_block.GetIsTrueOrFalse(true));
            initData.AddBlock(_block.GetPenaltyStatus(true));
            base.Initialize(initData);
        }

        /// <summary>
        /// 列表中修改、删除前设置属性、参数
        /// 传递到后台代码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnBeforeAction(object sender, EventArgs e)
        {
            EFViewCmesProperty _view = new EFViewCmesProperty();
            _view.EFGridCheckedRows = this.Grid.GetCheckedEIRows();
            base.ViewProperty = _view;
        }

        /// <summary>
        /// “打印”按钮执行事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnPrintButtonClick(object sender, RoutedEventArgs e)
        {
            //IList<EIRow> _list = this.Grid.GetCheckedEIRows() == null ? new List<EIRow>() : this.Grid.GetCheckedEIRows();
            //StringBuilder fdKeyId = new StringBuilder();

            //if (_list.Count == 0)
            //{
            //    DialogParameters param = new DialogParameters();
            //    param.CancelButtonContent = "取消";
            //    param.OkButtonContent = "确定";
            //    param.Content = "请选择要打印的记录！";
            //    param.Header = "提示框";
            //    EFWindow.Alert(param);
            //    return;
            //}
            //else
            //{
            //    for (int i = 0; i < _list.Count; i++)
            //    {
            //        //string fdStatus = _list[i]["fdStatus"] == null ? "" : _list[i]["fdStatus"].ToString();
            //        //if (!"生效".Equals(fdStatus))
            //        //{
            //        //    DialogParameters param = new DialogParameters();
            //        //    param.CancelButtonContent = "取消";
            //        //    param.OkButtonContent = "确定";
            //        //    param.Content = "只能选择状态为生效的纪录！";
            //        //    param.Header = "提示框";
            //        //    EFWindow.Alert(param);
            //        //    return;
            //        //}
            //        if (i == _list.Count - 1)
            //        {
            //            fdKeyId.Append("'" + _list[i]["fdKeyId"].ToString() + "'");
            //            break;
            //        }
            //        fdKeyId.Append("'" + _list[i]["fdKeyId"].ToString() + "',"); ;
            //    }

            String fdClassify = this.fdClassify.Value==null?"":this.fdClassify.Value.ToString();
            String fdSendnoteDepartment = this.fdSendnoteDepartment.Value==null?"":HttpUtility.UrlEncode(this.fdSendnoteDepartment.Value.ToString());
            String fdSendnotePerson = this.fdSendnotePerson.Value==null?"":HttpUtility.UrlEncode(this.fdSendnotePerson.Value.ToString());
            String fdDepartmentName = this.fdDepartmentName.Value==null?"":HttpUtility.UrlEncode(this.fdDepartmentName.Value.ToString());
            String fdPeopleName = this.fdPeopleName.Value==null?"":HttpUtility.UrlEncode(this.fdPeopleName.Value.ToString());
            String fdIsSubmit = this.fdIsSubmit.Value==null?"":HttpUtility.UrlEncode(this.fdIsSubmit.Value.ToString());
            String fdBeginDate = this.fdBeginDate.Value==null?"":this.fdBeginDate.Value.ToString();
            String fdEndDate = this.fdEndDate.Value==null?"":this.fdEndDate.Value.ToString();
            Uri uri = Uploader.ConstructAbsoluteUri("../admin/RunmaxReport1.jsp?projectName=CMESReport&reportName=penaltyReport&pClassify=" + fdClassify +"&pSendnoteDepartment=" +fdSendnoteDepartment+"&pPeopleName=" +fdPeopleName+"&pDepartmentName=" +fdDepartmentName+"&pSendnotePerson=" +fdSendnotePerson+"&pIsSubmit=" +fdIsSubmit+"&pBeginDate=" +fdBeginDate+"&pEndDate=" +fdEndDate);
            HtmlPage.Window.Navigate(uri, "_blank");
           
        }
    }
}
